// createRouter:创建router实例
// createWebHistory : 创建history模式路由

import { createRouter, createWebHistory } from 'vue-router'
import Login from '@/views/Login/index.vue'
import Layout from '@/views/Layout/index.vue'
import Home from '@/views/Home/index.vue'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      component: Layout,
      children: [
        {
          path: '',
          component: Home
        }
      ]
    },
    {
      path: '/login',
      component: Login
    }
  ],
  // 路由行为的配置项 路由切换的时候自动滚到顶部
  scrollBehavior() {
    return {
      top: 0
    }
  }
})

export default router
